﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "GmStructure.h"
#include "NdbObjectSchematic.h"
#include "IExternalData.h"
#include "IStructureColumn.h"
#include "RegenDataId.h"
#include "NdbDataSchema.h"
#include "RegenDataSchema.h"

namespace gcmp
{
    class IInstance;
    struct StructureColumnInput;

    class StructureColumn : public NdbObjectSchematic, public IStructureColumn
    {
        DATA_BEGIN(gcmp, StructureColumn, gcmp::NdbObjectSchematic, D24C3FEC - 5F54 - 4579 - B383 - 14DB3307CD40 , gmstructure)
            DATA_TRANSIENT(IElement*, pOwnerElement)
            DATA(ConcreteStrengthGradeType, ConcreteStrengthGrade)
            DATA_REGEN(double, Volume)
        DATA_END

    public:
        static OwnerPtr<StructureColumn> Create(IInstance* pInstance, const StructureColumnInput* pInput);
        bool SetOwnerElement(IElement* pOwnerElement) { m_pOwnerElement = pOwnerElement; return true; }
        IElement* GetOwnerElement() { return m_pOwnerElement; }
        const IElement* GetOwnerElement() const { return m_pOwnerElement; }
        IDocument* GetDocument() const;
        ElementId GetOwnerElementId() const;
        virtual NdbObject* GetTopOwnerObject() const override;

#pragma region IStructureColumn接口
    public:
        DECLARE_STRUCTURE_INSTANCE_METHODS;

    public:
        virtual double GetVolume() const override { return GetVolume__(); }
        bool SetVolume(double volume) { SetVolume__(volume); return true; }
        virtual double GetHeight() const override;
#pragma endregion IStructureColumn接口

    public:
        void UpdateForWeakParentDeletion(const std::set<ElementId>& deletedElementIds);
        void ReportParents(IElementParentReporter& reporter) const;
        void GetCalculators(ICalculatorCollection* calculators) const;
        void ReportParameterDefinitions(std::vector<int>* pParamDefIds) const;
        OwnerPtr<IParameter> GetNativeParameter(int paramDefId) const;
        bool SetNativeParameter(const IParameter *param, std::wstring* errorMsg = nullptr);
        bool IsParameterModifiable(int paramDefId) const;
        void Report(const gcmp::ICopyContext & copyContext, gcmp::ICopyStrategyReporter& reporter) const;
    };
}
